// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   register_choose_ok.java

package stock.pay;

import include.nseer_db.nseer_db_backup1;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;

public class register_choose_ok extends HttpServlet
{

	public register_choose_ok()
	{
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		javax.servlet.ServletContext dbApplication = dbSession.getServletContext();
		HttpSession session = request.getSession();
		nseer_db_backup1 stock_db = new nseer_db_backup1(dbApplication);
		try
		{
			if (stock_db.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				String stock_ID = request.getParameter("stock_ID");
				String product_ID = request.getParameter("product_ID");
				String pay_ID = request.getParameter("pay_ID");
				String serial_number_group[] = request.getParameterValues("serial_number");
				String serial_number = "";
				if (serial_number_group != null)
				{
					for (int i = 0; i < serial_number_group.length; i++)
						serial_number = (new StringBuilder(String.valueOf(serial_number))).append(serial_number_group[i]).toString();

					String sql = (new StringBuilder("delete from stock_paying_temp where pay_ID='")).append(pay_ID).append("' and product_ID='").append(product_ID).append("' and stock_ID='").append(stock_ID).append("'").toString();
					stock_db.executeUpdate(sql);
					String sql1 = (new StringBuilder("insert into stock_paying_temp(pay_ID,product_ID,stock_ID,serial_number,amount) values('")).append(pay_ID).append("','").append(product_ID).append("','").append(stock_ID).append("','").append(serial_number).append("','").append(serial_number_group.length).append("')").toString();
					stock_db.executeUpdate(sql1);
					response.sendRedirect((new StringBuilder("stock/pay/register.jsp?pay_ID=")).append(pay_ID).toString());
				} else
				{
					response.sendRedirect((new StringBuilder("stock/pay/register_choose_bat_ok_c.jsp?product_ID=")).append(product_ID).append("&&stock_ID=").append(stock_ID).append("&&pay_ID=").append(pay_ID).toString());
				}
				stock_db.commit();
				stock_db.close();
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
